Quarto Example Image Reels

Code
pacman::p_load(slickR,
               magick,
               googledrive,
               purrr,
               fs,
               bslib)

The Adventure begins

Contents of envelope #1:

Code
newlogo <- image_scale(image_read("https://jeroen.github.io/images/Rlogo.png"))
oldlogo <- image_scale(image_read("https://jeroen.github.io/images/Rlogo-old.png"))
image_resize(c(oldlogo, newlogo), '200x150!') %>%
  image_background('white') %>%
  image_morph() %>%
  image_animate(optimize = TRUE)

Code
# Download earth gif and make it a bit smaller for vignette
earth <- image_read("https://jeroen.github.io/images/earth.gif") %>%
  image_scale("200x") %>%
  image_quantize(128)

earth

Code
rev(earth) %>% 
  image_flip() %>% 
  image_annotate("meanwhile in Australia", size = 20, color = "white")

Code
# Foreground image
banana <- image_read("https://jeroen.github.io/images/banana.gif")
banana <- image_scale(banana, "150")
image_info(banana)
# A tibble: 8 × 7
  format width height colorspace matte filesize density
  <chr>  <int>  <int> <chr>      <lgl>    <int> <chr>  
1 GIF      150    148 sRGB       TRUE         0 72x72  
2 GIF      150    148 sRGB       TRUE         0 72x72  
3 GIF      150    148 sRGB       TRUE         0 72x72  
4 GIF      150    148 sRGB       TRUE         0 72x72  
5 GIF      150    148 sRGB       TRUE         0 72x72  
6 GIF      150    148 sRGB       TRUE         0 72x72  
7 GIF      150    148 sRGB       TRUE         0 72x72  
8 GIF      150    148 sRGB       TRUE         0 72x72  
Code
# Background image
background <- image_background(image_scale(logo, "200"), "white", flatten = TRUE)

# Combine and flatten frames
frames <- image_composite(background, banana, offset = "+70+30")

# Turn frames into animation
animation <- image_animate(frames, fps = 10, optimize = TRUE)
print(animation)
# A tibble: 8 × 7
  format width height colorspace matte filesize density
  <chr>  <int>  <int> <chr>      <lgl>    <int> <chr>  
1 gif      200    150 sRGB       FALSE        0 72x72  
2 gif       94    100 sRGB       FALSE        0 72x72  
3 gif      125    117 sRGB       FALSE        0 72x72  
4 gif      108    113 sRGB       FALSE        0 72x72  
5 gif      108    100 sRGB       FALSE        0 72x72  
6 gif       92    100 sRGB       FALSE        0 72x72  
7 gif      113    118 sRGB       FALSE        0 72x72  
8 gif      119    113 sRGB       FALSE        0 72x72  

The Envelope

Code
create_animation <- function(video_path, output_fps = 10, optimize = TRUE, output_path = "output.gif") {
  # Read the video
  video <- image_read_video(video_path)
  
  # Turn frames into animation
  animation <- image_animate(video, fps = output_fps, optimize = optimize)
  
  # Print the animation
  print(animation)
  
  # Write the animation to a GIF file
  image_write(animation, output_path)
  
  cat("Animation saved as", output_path, "\n")
}

# Usage
demo_video_path <- "Site Image Reels Assets/PXL_20230911_004506245.TS~2.mp4"
create_animation(demo_video_path, output_path = "output.gif")
Code
list_of_videos <- fs::dir_ls(
  'Site Image Reels Assets',
  glob = "*.mp4"
)

# Vector of video filenames
envelope_loop_1_to_4 <- c(
  "envelope1.gif",
  "envelope2.gif",
  "envelope3.gif",
  "envelope4.gif"
)

# Iterate over the vector and create animations
purrr::walk2(list_of_videos,
             envelope_loop_1_to_4,
             \(x,y) create_animation(x,
                                     output_path = 
                                       paste0('Site Image Reels Assets/gifs/',
                                              y)
             )
             )

Chonk: The Enigmatic Discovery Chonk

Chonk: Journey Through the Cosmos Chonk

Chonk: Secrets of the Lost Kingdom Chonk

Chonk: Tales from the Haunted Forest Chonk

Chonk: The Quest for Eternal Wisdom Chonk